package com.leagueoflegends.controller;

import com.github.pagehelper.PageInfo;
import com.leagueoflegends.bean.ChampionPassiveVO;
import com.leagueoflegends.bean.ChampionSkin;
import com.leagueoflegends.bean.ChampionSkinDTO;
import com.leagueoflegends.bean.ChampionSkinVO;
import com.leagueoflegends.service.ChampionSkinService;
import org.apache.ibatis.annotations.ResultMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin//跨域
@Controller
@RequestMapping("/skin")
public class ChampionSkinController {

    @Autowired
    ChampionSkinService championSkinService;



    @GetMapping("/getSkin1")
    @ResponseBody
    public PageInfo<ChampionSkinDTO> pageList1(
            @RequestParam(value = "pageNum", defaultValue = "0") int pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
            @RequestParam(value = "type", defaultValue = "all") String type,
            @RequestParam(value = "find", defaultValue = "") String find
    ) {
        List<ChampionSkinDTO> lists = championSkinService.selectAll1(pageNum, pageSize,type, find);

        return PageInfo.of(lists);
    }

    /**
     * 进入皮肤管理界面查看所有皮肤
     * @return
     */
    @ResponseBody
    @GetMapping("/SelectChampionSkin")
    public List<ChampionSkin> SelectChampionSkin(){
        System.out.println("接收到了查询所有英雄皮肤的请求");
        return championSkinService.SelectChampionSkin();
    }

//    @ResponseBody
//    @GetMapping("/SelectNum")
//    public List<ChampionSkin> SelectNum(){
//        System.out.println("num为0的英雄");
//        return championSkinService.SelectNum();
//    }


    @RequestMapping("/ins")
    public String insert(@RequestBody ChampionSkin skin) {
        championSkinService.insert(skin);
        return "";
    }

    @RequestMapping("/del")
    public String deleteByChampionId(Integer championId) {
        championSkinService.deleteByChampionId(championId);
        return "";
    }

    @RequestMapping("/del-id")
    public String deleteById(Integer id) {
        championSkinService.deleteById(id);
        return "";
    }

    @RequestMapping("/upd")
    public String update(@RequestBody ChampionSkin skin) {
        championSkinService.update(skin);
        return "";
    }

    @ResponseBody
    @RequestMapping("/sel")
    public List<ChampionSkin> select(Integer championId) {
        return championSkinService.select(championId);
    }

//
//    @GetMapping("/getSkin")
//    @ResponseBody
//    public PageInfo<ChampionSkinVO> pageList(
//            @RequestParam(value = "pageNum", defaultValue = "0") int pageNum,
//            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
//            @RequestParam(value = "type", defaultValue = "all") String type,
//            @RequestParam(value = "find", defaultValue = "") String find
//    ) {
//        List<ChampionSkinVO> list = championSkinService.selectAll(pageNum, pageSize,type, find);
//        return PageInfo.of(list);
//    }
}
